package io.terminus.spzx.manager.config;

import io.terminus.spzx.manager.interceptor.LoginAuthInterceptor;
import io.terminus.spzx.manager.properties.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author lichunlong lcl253137@alibaba-inc.com
 * @Desc 用户登录验证的全局配置类
 * @Date 2024-04-13
 */
@Component
public class LoginAuthWebMvcConfigurer implements WebMvcConfigurer {

    // private static final List<String> EXCLUDE_PATH_PATTERN_LIST = List.of("/admin/system/index/login", "/admin/system/index/generateValidateCode");

    @Autowired
    private LoginAuthInterceptor loginAuthInterceptor;

    @Autowired
    private UserProperties userProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginAuthInterceptor).excludePathPatterns(userProperties.getExcludePathPatterns()).addPathPatterns("/**");
    }
}
